package pack2;

public class java12 {
    public static void main(String[] args) {
        int num = 63815;
        int arry[] = new int[5];
        for (int i = 4; i > -1; i--) {
            arry[i]=num%10;
            num/=10;
        }
        int max = 0;
        int maxi = 0;
        int min = 10;
        int mini = 0;
        int temp=0;
        for (int i = 0; i < 5; i++) {
            if (arry[i] > max) {
                max = arry[i];
                maxi = i;
            }
            if (arry[i] < min) {
                mini = i;
                min=arry[i];
            }
        }

        System.out.print(arry[mini]);
        for (int i = 0; i < 5; i++) {
            if(i==maxi||i==mini)
                continue;
            System.out.print(arry[i]);
        }
        System.out.print(arry[maxi]);
    }
}